package com.hongyuan.sellfitness.ui.home.view_mode;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.mvvmhabitx.bus.RxBus;
import com.hongyuan.sellfitness.base.ItemViewModel;
import com.hongyuan.sellfitness.data.rxbus.ChangeStoreMessage;
import com.hongyuan.sellfitness.ui.home.beans.MemberOsBean;

public class StoreListItemViwModel extends ItemViewModel<StoreListViewModel> {

    public ObservableField<MemberOsBean.ListBean> entity = new ObservableField<>();

    public StoreListItemViwModel(@NonNull StoreListViewModel viewModel, MemberOsBean.ListBean bean) {
        super(viewModel);

        entity.set(bean);
    }

    //改变选中的门店
    public BindingCommand changeStore = new BindingCommand(() -> {
        //更改全局os_id
        viewModel.userToken.setOs_id(String.valueOf(entity.get().getOs_id()));

        RxBus.getDefault().post(new ChangeStoreMessage(String.valueOf(entity.get().getOs_id())));
        viewModel.finish();
    });

}
